package guggaTests.collections.linkedList
{	
	import gugga.collections.linkedList.LinkedList;
	import gugga.collections.linkedList.LinkedListItem;
	
	import flexunit.framework.Assert;
	import flexunit.framework.AssertionFailedError;
	import flexunit.framework.TestCase;

	public class LinkedListTest extends TestCase
	{
		public function LinkedListTest(methodName:String=null)
		{
			super(methodName);
		}
		
		public function testConstructor() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			assertNotNull("linkedList should not be null after creation", linkedList);
			assertNotUndefined("linkedList should not be undefined after creation", linkedList);
		}
		
		public function testCount() : void
		{
			var linkedList : LinkedList = new LinkedList();
			
			assertEquals("linkedList should be empty right after its creation", 0, linkedList.Count);
			
			linkedList.insertHead("object1");
			assertEquals("linkedList should have 1 element after insertHead()", 1, linkedList.Count);
			
			linkedList.insertHead("object2");
			assertEquals("linkedList should have 2 elements after insertHead()", 2, linkedList.Count);
			
			linkedList.deleteHead();
			assertEquals("linkedList should have 1 element after deleteHead()", 1, linkedList.Count);
			
			linkedList.deleteHead();
			assertEquals("linkedList should have 0 element after deleteHead()", 0, linkedList.Count);
		}
		
		public function testInsertRemoveGetHead() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			
			linkedList.insertHead(object1);
			assertEquals("object1 should be the head now", object1, linkedList.getHead());
			
			linkedList.insertHead(object2);
			assertEquals("object2 should be the head now", object2, linkedList.getHead());
			
			linkedList.insertHead(object3);
			assertEquals("object3 should be the head now", object3, linkedList.getHead());
			
			linkedList.deleteHead();
			assertEquals("object2 should be the head now", object2, linkedList.getHead());
			
			linkedList.deleteHead();
			assertEquals("object1 should be the head now", object1, linkedList.getHead());
			
			linkedList.deleteHead();
			assertEquals("linkedList should be empty(all items deleted)", 0, linkedList.Count);
			
			linkedList.deleteHead();
			assertNull("linkedList.getHead() should be undefined(all items are deleted and linkedList is empty)", 
				linkedList.getHead());
		}
		
		public function testInsertRemoveGetTail() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			
			linkedList.insertTail(object1);
			assertEquals("object1 should be the tail now", object1, linkedList.getTail());
			
			linkedList.insertTail(object2);
			assertEquals("object2 should be the tail now", object2, linkedList.getTail());
			
			linkedList.insertTail(object3);
			assertEquals("object3 should be the tail now", object3, linkedList.getTail());
			
			linkedList.deleteTail();
			assertEquals("object2 should be the tail now", object2, linkedList.getTail());
			
			linkedList.deleteTail();
			assertEquals("object1 should be the tail now", object1, linkedList.getTail());
			
			linkedList.deleteTail();
			assertEquals("linkedList should be empty(all items deleted)", 0, linkedList.Count);
			
			linkedList.deleteTail();
			assertUndefined("linkedList.getTail() should be undefined(all items are deleted and linkedList is empty)", 
					linkedList.getTail());
		}
		
		public function testContains() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			
			assertTrue(
					"linkedList is empty, and should not contain any objects", 
					!linkedList.contains(object1)
					&& !linkedList.contains(object2)
					&& !linkedList.contains(object3));
			
			linkedList.insertHead(object1);
			assertTrue(
					"linkedList should contain only object1, after linkedList.insertHead(object1)", 
					linkedList.contains(object1)
					&& !linkedList.contains(object2)
					&& !linkedList.contains(object3));
			
			linkedList.insertHead(object2);
			assertTrue(
					"linkedList should contain only object1 and object2, after linkedList.insertHead(object2);", 
					linkedList.contains(object1)
					&& linkedList.contains(object2)
					&& !linkedList.contains(object3));
			
			linkedList.insertHead(object3);
			assertTrue(
					"linkedList should contain object1, object2 and object3, after linkedList.insertHead(object3);", 
					linkedList.contains(object1)
					&& linkedList.contains(object2)
					&& linkedList.contains(object3));
			
			linkedList.deleteHead();
			assertTrue(
					"linkedList should contain only object1 and object2, after deleteHead()", 
					linkedList.contains(object1)
					&& linkedList.contains(object2)
					&& !linkedList.contains(object3));
			
			linkedList.deleteHead();
			assertTrue(
					"linkedList should contain only object1, after deleteHead()", 
					linkedList.contains(object1)
					&& !linkedList.contains(object2)
					&& !linkedList.contains(object3));
			
			linkedList.deleteHead();
			assertTrue(
					"linkedList should be empty, and should not contain any objects (all items are deleted)", 
					!linkedList.contains(object1)
					&& !linkedList.contains(object2)
					&& !linkedList.contains(object3));
		}
	
		public function testGetFirstItemContaining() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			var fictiveObject:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			
			var linkedListItem:LinkedListItem = linkedList.getFirstItemContaining(object2);			
			assertNotNull(
					"linkedList.getFirstItemContaining(object2) should not be null", 
					linkedListItem);
			assertNotUndefined(
					"linkedList.getFirstItemContaining(object2) should not be undefined", 
					linkedListItem);
			assertEquals(
					"linkedList.getFirstItemContaining(object2).Data should equals object2", 
					object2, 
					linkedListItem.Data);
			
			var itemPredecessor:LinkedListItem = linkedList.getItemPredecessor(linkedListItem);			
			assertEquals(
					"the object3's item should precede the first object2's item", 
					object3, 
					itemPredecessor.Data);
			
			linkedListItem = linkedList.getFirstItemContaining(fictiveObject);
			assertNull(
					"linkedList.getFirstItemContaining(fictiveObject) should be null", 
					linkedListItem);
		}
		
		public function testGetFirstItemContainingAfter() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object(); 
			object1["id"] = "Object1";			
			var object2:Object = new Object();
			object2["id"] = "Object2";			
			var object3:Object = new Object();
			object3["id"] = "Object3";
						
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(object3);
			
			linkedListItem = linkedList.getFirstItemContainingAfter(object2, linkedListItem);
			
			assertNotNull("linkedList.getFirstItemContainingAfter(object3, ...) should not be null", 
					linkedListItem);
					
			assertNotUndefined("linkedList.getFirstItemContainingAfter(object3, ...) should not be undefined", 
					linkedListItem);
					
			assertEquals("linkedList.getFirstItemContainingAfter(object3, ...).Data should equals object2", 
					object2, 
					linkedListItem.Data);
					
			var itemPredecessor:LinkedListItem = linkedList.getItemPredecessor(linkedListItem);
			
			assertEquals("object3's item should precede the first object2's item", 
					object3, 
					itemPredecessor.Data);
		}
		
		public function testGetItemPredecessor() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(object1);
			
			var itemPredecessor:LinkedListItem 
				= linkedList.getItemPredecessor(linkedListItem);
			assertEquals(
					"the object2's item should precede the object1's item", 
					object2, 
					itemPredecessor.Data);
			
			linkedListItem = itemPredecessor;
			itemPredecessor = linkedList.getItemPredecessor(linkedListItem);
			assertEquals(
					"the object3's item should precede the first object2's item", 
					object3, 
					itemPredecessor.Data);
			
			linkedListItem = itemPredecessor;
			itemPredecessor = linkedList.getItemPredecessor(linkedListItem);
			assertNull(
					"object3's item has no predecessor, so the itemPredecessor should be null", 
					itemPredecessor);
			
			var fictiveItem:LinkedListItem = new LinkedListItem();
			fictiveItem.NextItem = null;
			fictiveItem.Data = "fictive data";
			
			itemPredecessor = linkedList.getItemPredecessor(fictiveItem);
			assertNull(
					"fictiveItem has no predecessor, so the itemPredecessor should be null", 
					itemPredecessor);
		}
		
		public function testIsHead() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			assertTrue("object1 is head now", linkedList.isHead(object1));
			
			linkedList.insertHead(object2);
			assertTrue("object2 is head now", linkedList.isHead(object2));
			
			linkedList.deleteHead();
			assertTrue("object1 is head now", linkedList.isHead(object1));
			
			linkedList.deleteHead();
			assertFalse("there is no head now", linkedList.isHead(object1));
		}
		
		public function testIsTail() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertTail(object1);
			assertTrue("object1 is tail now", linkedList.isTail(object1));
			
			linkedList.insertTail(object2);
			assertTrue("object2 is tail now", linkedList.isTail(object2));
			
			linkedList.deleteTail();
			assertTrue("object1 is tail now", linkedList.isTail(object1));
			
			linkedList.deleteTail();
			assertFalse("there is no tail now", linkedList.isTail(object1));
		}
		
		public function testInsertBeforeGeneralCase() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			object2["id"] = "SomeData";
			var object3:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			
			var linkedListItem:LinkedListItem = linkedList.getFirstItemContaining(object2);
			
			var newObject:Object = new Object();
			
			linkedList.insertBefore(linkedListItem, newObject);
			
			linkedListItem = linkedList.getFirstItemContaining(newObject);
			var itemPredecessor:LinkedListItem = linkedList.getItemPredecessor(linkedListItem);
			
			assertEquals(
					"newObject's item predecessor should be object3's item", 
					object3, 
					itemPredecessor.Data);
			assertEquals(
					"newObject's item should succeed object3's item", 
					newObject,
					itemPredecessor.NextItem.Data);
			assertEquals(
					"newObject's item should precede object2's item", 
					object2, 
					linkedListItem.NextItem.Data);
		}
		
		public function testInsertBeforeHead() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			
			var newObject:Object = new Object();
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(linkedList.getHead());
			
			linkedList.insertBefore(linkedListItem, newObject);
			
			linkedListItem = linkedList.getFirstItemContaining(newObject);
			var itemPredecessor:LinkedListItem 
				= linkedList.getItemPredecessor(linkedListItem);
			
			assertNull(
					"newObject's item has no predecessor", 
					itemPredecessor);
			assertEquals(
					"now newObject should be the head",
					newObject,
					linkedList.getHead());
			assertEquals(
					"newObject's item should precede object2's item", 
					object2, 
					linkedListItem.NextItem.Data);
		}
		
		public function testInsertBeforeUnexistingItem() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			
			var fictiveObject:Object = new Object();
			var newObject:Object = new Object();
			
			var fictiveLinkedListItem:LinkedListItem = new LinkedListItem();
			fictiveLinkedListItem.NextItem = null;
			fictiveLinkedListItem.Data = fictiveObject;
			
			// try to insert before fictive item:
			linkedList.insertBefore(fictiveLinkedListItem, newObject);
			
			assertFalse(
					"newObject should not be inserted to the linkedLisk", 
					linkedList.contains(newObject));
			assertEquals(
					"the size of the linkedList should be the same after insertion before a fictive item",
					2,
					linkedList.Count);
		}
		
		public function testInsertAfterGeneralCase() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			
			var newObject:Object = new Object();
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(object2);
			
			linkedList.insertAfter(linkedListItem, newObject);
			
			linkedListItem = linkedList.getFirstItemContaining(newObject);
			var itemPredecessor:LinkedListItem 
				= linkedList.getItemPredecessor(linkedListItem);
			
			assertEquals(
					"newObject's item predecessor should be object2's item", 
					object2, 
					itemPredecessor.Data);
			assertEquals(
					"newObject's item should succeed object2's item", 
					newObject,
					itemPredecessor.NextItem.Data);
			assertEquals(
					"newObject's item should precede object1's item", 
					object1, 
					linkedListItem.NextItem.Data);
		}
		
		public function testInsertAfterTail() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			
			var newObject:Object = new Object();
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(linkedList.getTail());
			
			linkedList.insertAfter(linkedListItem, newObject);
			
			linkedListItem = linkedList.getFirstItemContaining(newObject);
			var itemPredecessor:LinkedListItem 
				= linkedList.getItemPredecessor(linkedListItem);
			
			assertNull(
					"newObject's item has no successors", 
					linkedListItem.NextItem);
			assertEquals(
					"now newObject should be the tail",
					newObject,
					linkedList.getTail());
			assertEquals(
					"newObject's item should succeed object1's item", 
					object1, 
					itemPredecessor.Data);
		}
		
		public function testInsertAfterUnexistingItem() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			
			var fictiveObject:Object = new Object();
			var newObject:Object = new Object();
			
			var fictiveLinkedListItem:LinkedListItem = new LinkedListItem();
			fictiveLinkedListItem.NextItem = null;
			fictiveLinkedListItem.Data = fictiveObject;
			
			// try to insert after fictive item:
			linkedList.insertAfter(fictiveLinkedListItem, newObject);
			
			assertFalse(
					"newObject should not be inserted to the linkedLisk", 
					linkedList.contains(newObject));
			assertEquals(
					"the size of the linkedList should be the same after insertion before a fictive item",
					2,
					linkedList.Count);
		}
		
		public function testDeleteItemGeneralCase() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(object2);
			
			linkedList.deleteItem(linkedListItem);
			
			assertFalse(
					"linkedList should not contain object2's item(object2's item was deleted)", 
					linkedList.contains(object2));
			assertEquals(
					"linkedList should contain 2 elements after deleting object2's item", 
					2, 
					linkedList.Count);
			
			linkedListItem = linkedList.getFirstItemContaining(linkedList.getHead());
			
			assertEquals(
					"object3's successor should be object1's item", 
					object1, 
					linkedListItem.NextItem.Data);
		}
		
		public function testDeleteItemHeadOrTail() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			var object4:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			linkedList.insertHead(object4);
			
			var linkedListHeadItem:LinkedListItem 
				= linkedList.getFirstItemContaining(linkedList.getHead());
			
			linkedList.deleteItem(linkedListHeadItem);
			assertFalse(
					"linkedList should not contain object4's item(object4's item was deleted)", 
					linkedList.contains(object4));
			assertEquals(
					"linkedList should contain 3 elements after deleting object4's item", 
					3, 
					linkedList.Count);
			assertEquals(
					"linkedList head now should be the object3's item", 
					object3, 
					linkedList.getHead());
			
			var linkedListTailItem:LinkedListItem 
				= linkedList.getFirstItemContaining(linkedList.getTail());
			
			linkedList.deleteItem(linkedListTailItem);
			assertFalse(
					"linkedList should not contain object1's item(object1's item was deleted)", 
					linkedList.contains(object4));
			assertEquals(
					"linkedList should contain 2 elements after deleting object1's item", 
					2, 
					linkedList.Count);
			assertEquals(
					"linkedList tail now should be the object2's item", 
					object2, 
					linkedList.getTail());
		}
		
		public function testDeleteItemUnexistingItem() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			
			var fictiveObject:Object = new Object();
			var fictiveItem:LinkedListItem = new LinkedListItem();
			fictiveItem.NextItem = null;
			fictiveItem.Data = fictiveObject;
			
			// try to delete the unexisting item:
			linkedList.deleteItem(fictiveItem);
			assertTrue(
					"linkedList should remain intact after deleting fictiveItem(should still containing object1, object2 and object3)", 
					linkedList.contains(object1) 
					&& linkedList.contains(object2) 
					&& linkedList.contains(object3)
					&& !linkedList.contains(fictiveObject));
			assertEquals(
					"linkedList should be still 3 after deleting fictiveItem", 
					3, 
					linkedList.Count);
			assertEquals(
					"linkedList head should be the object3's item after deleting fictiveItem", 
					object3, 
					linkedList.getHead());
			assertEquals(
					"linkedList tail should be the object1's item after deleting fictiveItem", 
					object1, 
					linkedList.getTail());
		}
		
		public function testDeleteBeforeGeneralCase() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			var object4:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			linkedList.insertHead(object4);
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(object2);
			
			// this should delete object3's item:
			linkedList.deleteBefore(linkedListItem);
			assertFalse(
					"linkedList should not contain object3's item(object3's item was deleted)", 
					linkedList.contains(object3));
			assertEquals(
					"linkedList should contain 3 elements after deleting object3's item", 
					3, 
					linkedList.Count);
			
			var itemPredecessor:LinkedListItem 
				= linkedList.getItemPredecessor(linkedListItem);
			assertEquals(
					"object2's item predecessor should be object4's item, after deleting object3's item",
					object4, 
					itemPredecessor.Data);
		}
		
		public function testDeleteBeforeHead() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(linkedList.getHead());
			
			linkedList.deleteBefore(linkedListItem);
			assertEquals(
					"linkedList should still contain 2 elements(there are no items before the head)", 
					2, 
					linkedList.Count);
			assertTrue(
					"linkedList should still contain object1 and object2", 
					linkedList.contains(object1) 
					&& linkedList.contains(object2));
			assertEquals(
					"linkedList head should still be object2's item", 
					object2, 
					linkedList.getHead());
		}
		
		public function testDeleteBeforeUnexistingItem() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			
			var fictiveObject:Object = new Object();
			var fictiveItem:LinkedListItem = new LinkedListItem();
			fictiveItem.NextItem = null;
			fictiveItem.Data = fictiveObject;
			
			linkedList.deleteBefore(fictiveItem);
			assertEquals(
					"linkedList should still contain 2 elements(there are no items before fictiveItem)", 
					2, 
					linkedList.Count);
			assertTrue(
					"linkedList should still contain object1 and object2", 
					linkedList.contains(object1) 
					&& linkedList.contains(object2)
					&& !linkedList.contains(fictiveObject));
			assertEquals(
					"linkedList head should still be object2's item", 
					object2, 
					linkedList.getHead());
		}
		
		public function testDeleteAfterGeneralCase() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			var object3:Object = new Object();
			var object4:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			linkedList.insertHead(object3);
			linkedList.insertHead(object4);
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(object3);
			
			// this should delete object3's item:
			linkedList.deleteAfter(linkedListItem);
			assertFalse(
					"linkedList should not contain object2's item(object2's item was deleted)", 
					linkedList.contains(object2));
			assertEquals(
					"linkedList should contain 3 elements after deleting object2's item", 
					3, 
					linkedList.Count);
			
			linkedListItem = linkedList.getFirstItemContaining(object1);
			var itemPredecessor:LinkedListItem 
				= linkedList.getItemPredecessor(linkedListItem);
			assertEquals(
					"object1's item predecessor should be object3's item, after deleting object2's item",
					object3, 
					itemPredecessor.Data);
		}
		
		public function testDeleteAfterTail() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			
			var linkedListItem:LinkedListItem 
				= linkedList.getFirstItemContaining(linkedList.getTail());
			
			linkedList.deleteAfter(linkedListItem);
			assertEquals(
					"linkedList should still contain 2 elements(there are no items after the tail)", 
					2, 
					linkedList.Count);
			assertTrue(
					"linkedList should still contain object1 and object2", 
					linkedList.contains(object1) 
					&& linkedList.contains(object2));
			assertEquals(
					"linkedList tail should still be object1's item", 
					object1, 
					linkedList.getTail());
		}
		
		public function testDeleteAfterUnexistingItem() : void
		{
			var linkedList:LinkedList = new LinkedList();
			
			// objects to be add:
			var object1:Object = new Object();
			var object2:Object = new Object();
			
			linkedList.insertHead(object1);
			linkedList.insertHead(object2);
			
			var fictiveObject:Object = new Object();
			var fictiveItem:LinkedListItem = new LinkedListItem();
			fictiveItem.NextItem = null;
			fictiveItem.Data = fictiveObject;
			
			linkedList.deleteAfter(fictiveItem);
			assertEquals(
					"linkedList should still contain 2 elements(there are no items before fictiveItem)", 
					2, 
					linkedList.Count);
			assertTrue(
					"linkedList should still contain object1 and object2", 
					linkedList.contains(object1) 
					&& linkedList.contains(object2)
					&& !linkedList.contains(fictiveObject));
			assertEquals(
					"linkedList tail should still be object1's item", 
					object1, 
					linkedList.getTail());
		}
	}
}